﻿using System.Windows.Input;
using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using Mal.Balades.Admin.Services;

namespace Mal.Balades.Admin.ViewModels.VisitViewModels.Dashboard
{
    //public delegate void VisitEditEventHandler(VisitDashboardViewModel visit);

    public class VisitDashboardViewModel : ViewModelBase
    {
        #region Fields
        private IVisitDashboard sourceVisit;
        private RelayCommand editCommand;

        private bool isValid;



        #endregion

        #region Construction / Destruction
        public VisitDashboardViewModel(IVisitDashboard visit)
        {
            this.SourceVisit = visit;
        }
        #endregion

        #region enum, struct, class

        #endregion

        #region Properties
        public IVisitDashboard SourceVisit
        {
            get { return sourceVisit; }
            private set
            {
                if (sourceVisit != value)
                {
                    sourceVisit = value;
                    RaisePropertyChanged("SourceVisit");

                    this.IsValid = this.sourceVisit.QualityCategories
                        && this.sourceVisit.QualityGps
                        && this.sourceVisit.QualityInformations
                        && this.sourceVisit.QualityPictures
                        && this.sourceVisit.QualitySumUp
                        && this.sourceVisit.QualityText
                        && this.sourceVisit.Visible;

                }
            }
        }

        public ICommand EditCommand
        {
            get
            {
                if (this.editCommand == null)
                {
                    this.editCommand = new RelayCommand(OnEdit);
                }
                return this.editCommand;
            }
        }

        public bool IsValid
        {
            get { return isValid; }
            set
            {
                if (isValid != value)
                {
                    isValid = value;
                    RaisePropertyChanged("IsValid");
                }
            }
        }

        #endregion

        #region Methods
        protected void OnEdit()
        {
            NavigationHelper.EditVisit(this, this.SourceVisit.VisitID);
        }

        protected bool CanEdit()
        {
            return true;
        }


        #endregion

        #region Events

        #endregion


    }
}
